package com.bearhy.jqadmin.controller;

import com.alibaba.fastjson.JSONObject;
import com.bearhy.jqadmin.common.BaseResult;
import com.bearhy.jqadmin.model.JqadminUser;
import com.bearhy.jqadmin.service.JqadminUserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class JqadminUserController {

    @Autowired
    private JqadminUserService jqadminUserService;
    @Autowired
    private ObjectMapper objectMapper;

    @RequestMapping("getAll")
    @ResponseBody
    public BaseResult getAll() throws JsonProcessingException {
        List<JqadminUser> list = jqadminUserService.getAll();
        BaseResult result = new BaseResult(list);
        //System.out.println(JSONObject);
        String string = objectMapper.writeValueAsString(result);
        System.out.println("getAll():"+string);
        return result;
    }
}
